\section{Introduction}
\begin{figure}[!ht]
\begin{center}
\includegraphics[angle=0, width=1.0\textwidth]{./Figures/cavity_junction.eps}
\end{center}
\caption{Generalized scatterering junction with P arbitrary ports,
with each port supporting an infinite number of modes.}\label{fig:cavity_junction}
\end{figure}

Consider a volume $V$ enclosed by a surface $S$ as depicted in Figure \ref{fig:cavity_junction}, where the unit vector $\hat{n}$ is normal to the surface $S$ and directed outward. Let the surface $S$ be divided into non-overlapping, connected sub-surfaces $\Delta S_p$ where the remaining surface $\Delta S_0$ is defined to be a PEC, so that,
\begin{align}
	S = \sum_{p=0}^P \Delta S_p
\end{align}
\subsection{Waveguide Port Expansion}
The surfaces $\Delta{S}_p$ are defined to be waveguide ports enclosed by a PEC boundary, in which the cross section can be any arbitrary shape (see fig \ref{fig:cavity_junction} for examples).  If $\Delta{S}_p$ is planar then the waveguide port is defined as uniform, if it is non-planar it is defined as non-uniform.  Since each waveguide port is enclosed by a PEC and if the fields inside the region satisfies Maxwell's equations along with the boundary conditions, the fields in the port can be expanded as infinite number of solutions or modes.
Because of the linearity of Maxwell's equations, the tangential port fields can also be superimposed to obatin the following expansion, 
\begin{align}
	\vec{E}_\bot(\vec{r}) &= \sum_{p=1}^{P}\sum_{m=1}^{M_p}{\vec{e}_m^{[p]}}(\vec{r}_\perp)v_m^{[p]}(n)\label{eqn:basis_eport}\\
	\vec{H}_\bot(\vec{r}) &= \sum_{p=1}^{P}\sum_{m=1}^{M_p}{\vec{h}_m^{[p]}}(\vec{r}_\perp)i_m^{[p]}(n)\label{eqn:basis_hport}
\end{align}
where $M_p$ is an array that holds the total number of waveguide modes at port $p$.  The tangential electric and magnetic fields $[\vec{E}_\bot,\vec{H}_\bot]$ are a function of the independent variable $\vec{r} = \vec{r}_\perp+n\hat{n}$ where the transverse basis fields $[\vec{e},\vec{h}]$ are only a function of $\hat{r}_\perp$.  The waveguide modes are only defined over the area $\Delta S_p$ and outside this area they are defined to be zero.  This is important so that each individual port field and the fields over the pec surface can be superimposed to obtain the total fields.  Since the tangential electric fields over the pec surface ($\Delta S_0$) is equal to zero the summation starts at $p=1$ instead of $p=0$.

\subsection{Cavity Port Expansion}
The fields inside the cavity $[\vec{E}_c, \vec{H}_c]$ are expanded as the summation of simplified cavities, where all of the ports except for port $q$ are short-circuited by placing a PEC over the port \cite{Kuhn:1973}.  If the geometry is restricted to configurations where the cavity walls conicide with the coordinate planes of an orothogonal coordinate system and seperation of variables is used, then the fields of the simplified cavities can be expanded as an infinte set of modes such that,
\begin{align}
	\vec{E}_{c}(\vec{r}) &= \sum_{p=1}^{P}\sum_{m=1}^{N_p}(\vec{e}_c)_m^{[p]}(\vec{r})C_m^{[p]}\label{eqn:basis_ecavity}\\
	\vec{H}_{c}(\vec{r}) &= \sum_{p=1}^{P}\sum_{m=1}^{N_p}(\vec{h}_c)_m^{[p]}(\vec{r})C_m^{[p]}\label{eqn:basis_hcavity}
\end{align}
where $C$ is a constant for the simplified cavity $q$ and cavity mode $n$.

\subsection{Matching Port and Cavity Fields with Bounary Conditions}
The surface S defines a boundary in which the total tangential fields inside the cavity and outside the cavity must match.  The fields outside the cavity include the port fields $\Delta S_p$ and the fields over the pec surface $\Delta S_0$.  In general they  must satisfy the boundary conitions,
\begin{align}
 \hat{n}\times(\vec{E}_\bot-\vec{E}_c)&=-\vec{M}_s\label{eqn:bce0}\\
 \hat{n}\times(\vec{H}_\bot-\vec{H}_c)&=\vec{J}_s\label{eqn:bch0}
\end{align}
which is valid over the entire surface $S$ and is evaluated on the surface $\vec{r}_s$.  This reduces the problem space to two dimensions.  

It is convenient to describe each of the port fields and the cavity fields in it's own local coordinate system.  But, it is important to realize that before the boundary conditons can be applied, each field must be expanded in the same coordinate system, or one must be rotated and translated into the coordinate sytem of the other. In this work, the cavity fileds will be rotated and translated into the port fields.  This allows for the expansion of the port fields to be kept general.  

The fields outside the cavity include the port fields and the fields over the
PEC surface.  Dividing the fields into these regions, the boundary conditions
can be written as,
\begin{align}
\hat{n}\times\vec{E}_c = \left\{
\begin{array}{ll}
\vec{M}_s & \text{on PEC surface } \Delta S_0\\
\hat{n}\times\vec{E}_\bot & \text{on port surfaces }  S-\Delta S_0
\end{array} \right.
\end{align}
\begin{align}
\hat{n}\times\vec{H}_c = \left\{
\begin{array}{ll}
-\vec{J}_s & \text{on PEC surface } \Delta S_0\\
\hat{n}\times\vec{H}_\bot & \text{on port surfaces }  S-\Delta S_0
\end{array} \right.
\end{align}
The port fields are defined over their respective port region, and are
defined to be equal to zero outside of this region. Using this fact and that
Maxwell's equations are linear, the fields can be superimposed as,
\begin{align}
 \hat{n}\times\vec{E}_c&=\hat{n}\times\vec{E}_\bot+\vec{M}_s\label{eqn:bce1}\\
 \hat{n}\times\vec{H}_c&=\hat{n}\times\vec{H}_\bot-\vec{J}_s\label{eqn:bch1}
\end{align}
which is defined over the entire surface $S$.

For the fields to be unique in the cavity region, the boundary conditions on
the surface $S$ must specify the tangential electric fields over the entire
boundary or the tangential magnetic fields over the entire boundary, or the
former over part of the bouandary and the latter over the rest.  In this
analysis, only the tangential electric fields specified over the surface will
be of interest.  Therfore, the tangential magnetic fields of equivalent
surface currents over the pec surface are left unspecified. The magnetic
surface currents ($\vec{M}_s$) over the PEC surface are equal to zero, therfore
the boundary condition redcue to,
\begin{align}
 \hat{n}\times\vec{E}_c&=\hat{n}\times\vec{E}_\bot \quad \text{over
 entire surface }S\label{eqn:bce2}\\
 \hat{n}\times\vec{H}_c&=\hat{n}\times\vec{H}_\bot \quad \text{on port
 surfaces }  (S-\Delta S_0)\label{eqn:bch2}
\end{align}

Substituting the expanded port fields (\ref{eqn:basis_eport}) and
(\ref{eqn:basis_hport}) and the expanded cavity fields
(\ref{eqn:basis_ecavity}) and (\ref{eqn:basis_hcavity}) into the boundary
conditions (\ref{eqn:bce2}) and (\ref{eqn:bch2}) yields,
\begin{align}
 \hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{N_p}(\vec{e}_c)_m^{[p]}(\vec{r})C_m^{[p]}&=\hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{M_p}{\vec{e}_m^{[p]}}(\vec{r}_\perp)v_m^{[p]}(n)\label{eqn:bce3}\\
 \hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{N_p}(\vec{h}_c)_m^{[p]}(\vec{r})C_m^{[p]}&=\hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{M_p}{\vec{h}_m^{[p]}}(\vec{r}_\perp)i_m^{[p]}(n)\label{eqn:bch3}
\end{align}

\subsection{Discretization by Method of Moments}

In order to discretize these equations, method of moments is used where an
inner product operator ${<\{\bullet\},w(\hat{r}_s)>}$ is defined and testing is
accomplished with a weighting function.  For the e-field match (\ref{eqn:bce3})
the magnetic basis vectors from the cavity $(\vec{h}_c)_n^{[q]}$ is used as a
testing function and for the h-field match (\ref{eqn:bch3}) the electric basis
vectors from the ports $\vec{e}_n^{[q]}$ are used \cite{Eleftheriades:1994},
\cite{Morini:2001}.  The inner product for the e-field match and the h-field
match with their weighting functions substituted are defined as follows,
\begin{align}
	{<\{\bullet\},(\vec{h}_c)_n^{[q]}>} &= \oiint_S \{\bullet\}\cdot(\vec{h}_c)_n^{[q]}\;ds\label{eqn:innerprod_h}\\ 
	{<\{\bullet\},\vec{e}_n^{[q]}>} &= \iint_{\Delta S_q} \{\bullet\}\cdot\vec{e}_n^{[q]}\;ds\label{eqn:innerprod_e}
\end{align}
Applying (\ref{eqn:innerprod_h}) to both sides of (\ref{eqn:bce3}) and applying
(\ref{eqn:innerprod_e}) to both sides of (\ref{eqn:bch3}) yields,
\begin{align}
	\oiint_S \hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{N_p}(\vec{e}_c)_m^{[p]}C_m^{[p]}\cdot(\vec{h}_c)_n^{[q]}\;ds &= \oiint_S \hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{M_p}{\vec{e}_m^{[p]}}v_m^{[p]}\cdot(\vec{h}_c)_n^{[q]}\;ds\label{eqn:bce4}\\ 
	\iint_{\Delta S_q} \hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{N_p}(\vec{h}_c)_m^{[p]}C_m^{[p]}\cdot\vec{e}_n^{[q]}\;ds &= \iint_{\Delta S_q} \hat{n}\times\sum_{p=1}^{P}\sum_{m=1}^{M_p}{\vec{h}_m^{[p]}}i_m^{[p]}\cdot\vec{e}_n^{[q]}\;ds\label{eqn:bch4}
\end{align}
Rearranging and simplifying gives,
\begin{align}
\sum_{p=1}^{P}\sum_{m=1}^{N_p}\iint_{\Delta S_p} (\vec{e}_c)_m^{[p]}\times(\vec{h}_c)_n^{[q]}\cdot\hat{n}\;ds\;C_m^{[p]} &= \sum_{p=1}^{P}\sum_{m=1}^{M_p}\iint_{\Delta S_p} {\vec{e}_m^{[p]}}\times(\vec{h}_c)_n^{[q]}\cdot\hat{n}\;ds\;v_m^{[p]}\label{eqn:bce5}\\
\sum_{p=1}^{P}\sum_{m=1}^{N_p}\iint_{\Delta S_q} \vec{e}_n^{[q]}\times(\vec{h}_c)_m^{[p]}\cdot\hat{n}\;ds\;C_m^{[p]} &= \sum_{p=1}^{P}\sum_{m=1}^{M_p}\iint_{\Delta S_q} \vec{e}_n^{[q]}\times\vec{h}_m^{[p]}\cdot\hat{n}\;ds\;i_m^{[p]}\label{eqn:bch5}
\end{align}
Note that the surface integral in (\ref{eqn:bce5}) collapsed around the port
surfaces $\Delta S_p$ since the pec boundary conditions made the rest of the
integral equal to zero. From (\ref{eqn:bch5}) let,
\begin{align}
	\int_{\Delta S_q} \vec{e}_n^{[q]}\times\vec{h}_m^{[p]}\cdot\hat{n}\;ds =
	\delta_{m,n}\delta_{p,q}
\end{align}
where $\delta_{m,n}$ is the kronecker delta function.  This says that the modes
in a given port are defined to be orthonormal.  The ports themselves are
orthogonal since they do not overlap and the integration is over only one port
area at a time.  From (\ref{eqn:bce5}) and (\ref{eqn:bch5}) the following
definitions are made,

There are N-ports feeding a scattering
junction.  Each of the ports have constant dimensions in the
longitudinal direction but are any arbitrary shape in the
transverse plane.  Each port is described in its own respective
coordinate system with the normal to the transverse plane as being
defined as pointing into the scattering junction.

The scattering matrix characterizes the scattering junction in
that it relates the incident $(\vec{a})$ and reflected $(\vec{b})$
waves of one port to the incident and reflected waves of all other
ports. This provides a complete description of the junction as
seen by its N ports. Each of the ports are waveguide ports, which
support an infinite set of waveguide modes. Because of the
orthogonality of waveguide modes, each mode can be considered as
an individual port in the scattering matrix. This is referred to
as a generalized scattering matrix.

Given the scattering matrices of more than one junction, these
junctions can be connected together at their ports to solve
complex problems. The \emph{mode matching} method, as used here,
refers to a three step process to solve such problems.
\begin{enumerate}
\item Expand the electric and magnetic fields of the ports in terms
of orthogonal basis vectors or modes.  These modes also need to be
normalized or weighted equally with respect to each other. This
will make the basis vectors orthonormal.
\item Solve the scattering problem specific to a given junction and geometry. This
relates the modes of each port as calculated in step one through a
generalized scattering matrix.
\item Connect the scattering matrices of the junctions together to get
an overall solution to the problem.
\end{enumerate}

\section{Expansion and Normalization of Basis Vectors}
The following steps outline the procedure for finding a basis set for expansion:
\begin{enumerate}
\item Choose the mode type and the direction of expansion (i.e. $TE_n$, or $TM_n$).  This does not have to be the same direction as propagation.
\item Separate Variables in terms of a transverse direction and a propagation direction where the transverse direction is only a function of the transverse variables and the propagation direction is only a function of a single variable which is normal to the transverse direction.
\item Expand the transverse functions as standing waves and the propagation function as traveling waves.
\item Apply boundary conditions in the transverse direction to obtain a discrete set of solutions.
\item Apply linearity to the basis set to obtain a sum of solutions.
\item Check that basis set is orthogonal.
\item Normalize the basis set to make an orthonormal basis set.  This is important since this normalization determines what type of scattering occurs (i.e. power, voltage or current).  For a generalized scattering matrix, power is the quantity of interest.  It is important to realize that the power is contained in the transverse fields and the incident and reflected waves are proportional to this power, therefore all the modes in all the ports must be weighted equally in terms of power in the transverse fields.
\item Calculate power in terms of basis set expansion and make sure power is conserved.  If it is not conserved then a new set of testing functions will need to be defined.
\end{enumerate}

\subsection{Uniform Waveguide Basis Vectors}
	Uniform waveguide basis vectors are defined as \ldots (look up in Marcuvitz
	for definition). Uniform waveguides have uniform or planar cross-sections.
	
\subsubsection{$TM_n$ Uniform Waveguide Basis Vectors}
From equation (\ref{eqn:transmissionlinefield}), $A_n(\vec{r})$ will be defined as
\begin{align}
    A_n(\vec{r})&={C_A}a_n(\vec{r}_\bot)I(n)\\
    &=C_{A}a_n(\vec{r}_\bot)\frac{i(n)}{\sqrt{Z_A}}\label{eqn:sepfcnsTM}
\end{align}
where $C_A$ is a normalization constant and a $TM$ wave impedance is defined as
\begin{align}
	Z_A&=\frac{(\gamma_n=jk_n)}{j\omega\varepsilon'}\label{eqn:ZA}
\end{align}
Also, $I(n)$ is the total current in the normal direction were $i(n)$ is a normalized current defined by,
\begin{align}
i(n) = \sqrt{Z_A}I(n)
\end{align}
and has units of $\sqrt{W}$.
Using this notation the normalized current $i(n)$ is expanded into traveling waves as,
\begin{align}
\begin{split}
    i(n)&=i_0^+e^{-\gamma_nn}-i_0^-e^{\gamma_nn}\\
    &=i_0^+e^{-jk_nn}-i_0^-e^{jk_nn}\\
    &=b(n)-a(n)\label{eqn:solnscalarwavenormTM}
\end{split}
\end{align}
and (\ref{eqn:solnscalarwavenormderiv}) is,
\begin{align}
\begin{split}
    \frac{di(n)}{dn}&=-\gamma_n(i^+e^{-\gamma_nn}+i^-e^{\gamma_nn})\\
    &=-j k_n(i^+e^{-jk_nn}+i^-e^{jk_nn})\\
    &=-(\gamma_n=j k_n)\bigr(b(n)+a(n)\bigl)\label{eqn:solnscalarwavenormderivTM}
\end{split}
\end{align}
where $a(n)$ in defined as a wave that is incident on the port and $b(n)$ is defined as a wave reflected from the port.  Note that (\ref{eqn:solnscalarwavenormTM}) is defined as the difference of forward and backward traveling waves.  This was done so that electric fields for both the $TE$ and $TM$ cases would be proportional to the sum of the forward and backward traveling waves while the magnetic fields for the $TE$ and $TM$ cases would be proportional to the difference of the forward and backward traveling waves. 
Using (\ref{eqn:sepfcnsTM}) and
(\ref{eqn:solnscalarwavenormderivTM}), equation (\ref{eqn:EperpTM})
reduces to,
\begin{align}
    \vec{E}^A_\bot&=\frac{1}{j\omega\varepsilon'}\vec{\nabla}_\bot\frac{\partial{A_n}}{\partial n}\label{eqn:EAperpBasis1}\\
    &=\frac{1}{j\omega\varepsilon'}\frac{C_A}{\sqrt{Z_A}}\vec{\nabla}_\bot a_n(\vec{r_\bot})\frac{d{i(n)}}{dn}\label{eqn:EAperpBasis2}\\
    &=\frac{-(\gamma_n=j k_n)}{j\omega\varepsilon'}\frac{C_A}{\sqrt{Z_A}}\vec{\nabla}_\bot a_n(\vec{r_\bot})\bigr(b(n)+a(n)\bigl)\label{eqn:EAperpBasis3}
\end{align}
and then substituting (\ref{eqn:ZA}) gives,
\begin{align}
\vec{E}^A_\bot&=-C_A\sqrt{Z_A}\vec{\nabla}_\bot a_n(\vec{r_\bot})\bigr(b(n)+a(n)\bigl)\label{eqn:EAperpBasis4}
\end{align}
Using (\ref{eqn:sepfcnsTM})--(\ref{eqn:solnscalarwavenormTM}), equation (\ref{eqn:HperpTM})
reduces to,
\begin{align}
    \vec{H}^A_\bot&=\vec{\nabla}_\bot A_n\times\hat{n}\label{eqn:HperpA2Basis1}\\
    &=\frac{C_A}{\sqrt{Z_A}}\bigl(\vec{\nabla}_\bot a_n(\vec{r_\bot})\times\hat{n}\bigr)\bigr(b(n)-a(n)\bigl)\label{eqn:HperpA2Basis2}
\end{align}
If the direction of propagation in assumed to be in the $\hat{n}$ direction then the basis vectors for $TM_n$ modes are the following,
\begin{align}
    \vec{e}_A&=-C_A\sqrt{Z_A}\vec{\nabla}_\bot a_n(\vec{r_\bot})\label{eqn:EABasis}\\
    \vec{h}_A&=\frac{C_A}{\sqrt{Z_A}}\vec{\nabla}_\bot a_n(\vec{r_\bot})\times\hat{n}\label{eqn:HABasis}
\end{align}

\subsubsection{$TE_n$ Uniform Waveguide Basis Vectors}
From equation (\ref{eqn:transmissionlinefield}), $F_n(\vec{r})$ will be defined as
\begin{align}
    F_n &= C_F f_n(\vec{r_\bot})V(n)\\
    &= C_Ff_n(\vec{r_\bot})\sqrt{Z_F}v(n)\label{eqn:sepfcnsTE}
\end{align}
where $C_F$ is a normalization constant and a $TE$ wave impedance is defined as 
\begin{align}
Z_F&=\frac{j\omega\mu'}{(\gamma_n=jk_n)}\label{eqn:ZF}
\end{align}
Also $V(n)$ is the total voltage in the normal direction where $v(n)$ is a normalized voltage defined as,
\begin{align}
v(n) = \frac{V(n)}{\sqrt{Z_F}}
\end{align}
and has units of $\sqrt{W}$.
Using this notation the normalized voltage $v(n)$ is expanded into traveling waves as,
(\ref{eqn:solnscalarwavenorm}) is defined as,
\begin{align}
    v(n)&=v_0^+e^{-\gamma_nn}+v_0^-e^{\gamma_nn}\\
    &=v_0^+e^{-jk_nn}+v_0^-e^{jk_nn}\\
    &=b(n)+a(n)\label{eqn:solnscalarwavenormTE}
\end{align}
and (\ref{eqn:solnscalarwavenormderiv}) is,
\begin{align}
    \frac{dv(n)}{dn}&=-\gamma_n(v^+e^{-\gamma_nn}-v^-e^{\gamma_nn})\\
    &=-j k_n(v^+e^{-jk_nn}-v^-e^{jk_nn})\\
    &=-(\gamma_n=j k_n)(b(n)-a(n))\label{eqn:solnscalarwavenormderivTE}
\end{align}
Using (\ref{eqn:sepfcnsTE}) and
(\ref{eqn:solnscalarwavenormderivTE}), equation (\ref{eqn:HperpTE})
reduces to,
\begin{align}
    \vec{H}^F_\bot&=\frac{1}{j\omega\mu'}\vec{\nabla}_\bot\frac{\partial{F_n}}{\partial n}\label{eqn:HFperpBasis1}\\
    &=\frac{1}{j\omega\mu'}C_F\sqrt{Z_F}\vec{\nabla}_\bot f_n(\vec{r_\bot})\frac{d{v(n)}}{dn}\label{eqn:HFperpBasis2}\\
    &=\frac{-(\gamma_n=j k_n)}{j\omega\mu'}C_F\sqrt{Z_F}\vec{\nabla}_\bot f_n(\vec{r_\bot})\bigr(b(n)-a(n)\bigl)\label{eqn:HFperpBasis3}
\end{align}
and then substituting (\ref{eqn:ZF}) gives,
\begin{align}
\vec{H}^F_\bot&=-\frac{C_F}{\sqrt{Z_F}}\vec{\nabla}_\bot f_n(\vec{r_\bot})\bigr(b(n)-a(n)\bigl)\label{eqn:HFperpBasis4}
\end{align}
Using (\ref{eqn:ZF}), (\ref{eqn:sepfcnsTE}) and
(\ref{eqn:solnscalarwavenormTE}), equation (\ref{eqn:EperpTE})
reduces to,
\begin{align}
    \vec{E}^F_\bot&=-\vec{\nabla}_\bot F_n\times\hat{n}\label{eqn:EperpF2Basis1}\\
    &=-C_F\sqrt{Z_F}\bigl(\vec{\nabla}_\bot
    f_n(\vec{r_\bot})\times\hat{n}\bigr)\bigr(b(n)+a(n)\bigl)\label{eqn:EperpF2Basis2}
\end{align}
If the direction of propagation in assumed to be in the $\hat{n}$ direction then the basis vectors for $TE_n$ modes are the following,
\begin{align}
    \vec{e}_F&=-C_F\sqrt{Z_F}\vec{\nabla}_\bot f_n(\vec{r_\bot})\times\hat{n}\label{eqn:EFBasis}\\
    \vec{h}_F&=-\frac{C_F}{\sqrt{Z_F}}\vec{\nabla}_\bot f_n(\vec{r_\bot})\label{eqn:HFBasis}
\end{align}

\subsubsection{Hybrid Basis Vectors}
Letting $C_A=C_F=C_H$.
and summing (\ref{eqn:HperpA2Basis2}) and (\ref{eqn:HFperpBasis3}), the
transverse magnetic fields are found to be,
\begin{equation}\label{eqn:HhybridTotal}
    \vec{H}_\bot(\vec{r})=
    C_H\biggl[\frac{\vec{\nabla}_\bot a_n(\vec{r_\bot})}{\sqrt{Z_A}}\times\hat{n}-\frac{\vec{\nabla}_\bot f_n(\vec{r_\bot})}{\sqrt{Z_F}}\biggr]\bigl(b(n)-a(n)\bigr)
\end{equation}
Summing (\ref{eqn:EperpF2Basis2})
and (\ref{eqn:EAperpBasis3}), the transverse electric fields are
found to be,
\begin{equation}\label{eqn:EhybridTotal}
    \vec{E}_\bot(\vec{r})=
    -C_H\biggl[\sqrt{Z_F}\vec{\nabla}_\bot f_n(\vec{r_\bot})\times\hat{n}+\sqrt{Z_A}\vec{\nabla}_\bot a_n(\vec{r_\bot})\biggr]\bigl(b(n)+a(n)\bigr)
\end{equation}
where $\vec{r}=\vec{r}_\bot+n\hat{n}$. The basis vectors for
hybrid modes are then equal to the following.
\begin{align}
    \vec{h}(\vec{r}_\bot)&=
		C_H\biggl[\frac{\vec{\nabla}_\bot a_n(\vec{r_\bot})}{\sqrt{Z_A}}\times\hat{n}-\frac{\vec{\nabla}_\bot f_n(\vec{r_\bot})}{\sqrt{Z_F}}\biggr]\label{eqn:hperpbasishybrid}\\
    \vec{e}(\vec{r}_\bot)&=
    -C_H\biggl[\sqrt{Z_F}\vec{\nabla}_\bot f_n(\vec{r_\bot})\times\hat{n}+\sqrt{Z_A}\vec{\nabla}_\bot a_n(\vec{r_\bot})\biggr]\label{eqn:eperpbasishybrid2}
\end{align}
\subsection{Non-uniform Waveguide Basis Vectors}
Non-uniform have cross-sections that are not planar.  Examples would be radial
waveguide ports.  This is discussed in another chapter.

\subsection{Application of Boundary Conditions}
When boundary conditions are applied a discrete set of solutions or modes are obtained.  There are two basic types of boundary conditions, namely \emph{Neumann} ($\frac{\partial\psi}{\partial{n}}=0$) and \emph{Dirichlet} ($\psi=0$).  These can be summed to get a generalized boundary condition or an impedance boundary condition as,
\begin{align}
\alpha_1\psi(\vec{r}_s)+\alpha_2\frac{\partial\psi(\vec{r}_s)}{\partial{u}}=0
\end{align}
where,
\begin{align}
\nabla_\bot\psi(\vec{r_s})\cdot\hat{u}=\frac{\partial\psi(\vec{r}_s)}{\partial{u}}
\end{align}
and where $\hat{u}$ is a unit vector directed normal to the boundary and $\vec{r}_s$ is evaluated on the boundary.

\subsection{Orthogonality and Normalization of Basis Vectors}\label{sec:norm_orthogonality}
The constants $C_A$ and $C_F$ in the basis functions are normalization constants and will be found to make the following condition true,
\begin{align}
    \iint_S\vec{e}\times\vec{h}\cdot\hat{n}\;ds&=1\label{eqn:reactionnorm}
\end{align}
This is seen as making the \emph{reaction} normalized to unity. \emph{Power} normalization is also another option with $\iint_S\vec{e}\times\vec{h}^*\cdot\hat{n}\;ds=1e^{j\phi}$, where $^*$ is the complex conjugate operator.  The reason power normalization is  not used is that the constants can only be chosen to make the magnitude of the fields equal to unity.  The phases are left unspecified. With \emph{reaction} normalization the constants are in general complex and can be chosen so that the integral in (\ref{eqn:reactionnorm}) is in fact equal to unity.

To compute the normalization constants, there are in general four cases as follows,
\begin{align}
    \iint_S\vec{e}\times\vec{h}\cdot\hat{n}\;ds&=
    \iint_S\bigl[(\vec{e}_A+\vec{e}_F)\times(\vec{h}_A+\vec{h}_F\bigr)]\cdot{n}\;ds\\
    &=\iint_S\vec{e}_A\times\vec{h}_A\cdot\hat{n}\;ds\label{eqn:inteAxhA}\\
    &+\iint_S\vec{e}_F\times\vec{h}_F\cdot\hat{n}\;ds\label{eqn:inteFxhF}\\
    &+\iint_S\vec{e}_F\times\vec{h}_A\cdot\hat{n}\;ds\label{eqn:inteFxhA}\\
    &+\iint_S\vec{e}_A\times\vec{h}_F\cdot\hat{n}\;ds\label{eqn:inteAxhF}
\end{align}
Substituting (\ref{eqn:EABasis}) and (\ref{eqn:HABasis}) and 
using the vector identity
$\vec{A}\times(\vec{B}\times\vec{C})=(\vec{A}\cdot\vec{C})\vec{B}-(\vec{A}\cdot\vec{B})\vec{C}$,
the integrand of (\ref{eqn:inteAxhA}) can be expressed as,
\begin{align}
\vec{e}_A\times\vec{h}_A\cdot\hat{n}&=-C_A^2\vec{\nabla}_\bot{}a_n\times\bigl(\vec{\nabla}_\bot{}a_n\times\hat{n}\bigr)\cdot\hat{n}\label{eqn:eAxhA1}\\
&=-C_A^2\underbrace{(\vec{\nabla}_\bot{}a_n\cdot\hat{n})}_{\hat{\bot}\cdot\hat{n}=0}\vec{\nabla}_\bot{}a_n\cdot\hat{n}+C_A^2\bigl(\vec{\nabla}_\bot{}a_n\cdot\vec{\nabla}_\bot{}a_n\bigr)\underbrace{\hat{n}\cdot\hat{n}}_{\hat{n}\cdot\hat{n}=1}\label{eqn:eAxhA2}\\
&=C_A^2\vec{\nabla}_\bot{}a_n\cdot\vec{\nabla}_\bot{}a_n\label{eqn:eAxhA3}
\end{align}
Similarly, substituting (\ref{eqn:HFBasis}) and (\ref{eqn:EFBasis}) and 
using the vector identity
$\vec{A}\times(\vec{B}\times\vec{C})=(\vec{A}\cdot\vec{C})\vec{B}-(\vec{A}\cdot\vec{B})\vec{C}$,
the integrand of (\ref{eqn:inteFxhF}) can be simplified to,
\begin{align}
\vec{e}_F\times\vec{h}_F\cdot\hat{n}&=-C_F^2\vec{\nabla}_\bot{}f_n\times\bigl(\vec{\nabla}_\bot{}f_n\times\hat{n}\bigr)\cdot\hat{n}\label{eqn:eFxhF1}\\
&=-C_F^2\underbrace{(\vec{\nabla}_\bot{}f_n\cdot\hat{n})}_{\hat{\bot}\cdot\hat{n}=0}\vec{\nabla}_\bot{}f_n\cdot\hat{n}+C_F^2\bigl(\vec{\nabla}_\bot{}f_n\cdot\vec{\nabla}_\bot{}f_n\bigr)\underbrace{\hat{n}\cdot\hat{n}}_{\hat{n}\cdot\hat{n}=1}\label{eqn:eFxFA2}\\
&=C_F^2\vec{\nabla}_\bot{}f_n\cdot\vec{\nabla}_\bot{}f_n\label{eqn:eFxhF3}
\end{align}
Substituting (\ref{eqn:EFBasis}) and (\ref{eqn:HABasis}) and 
using the vector identity
$\vec{A}\times(\vec{B}\times\vec{C})=(\vec{A}\cdot\vec{C})\vec{B}-(\vec{A}\cdot\vec{B})\vec{C}$, along with the vector identity $\vec{A}\times\vec{B}\cdot\vec{C}=\vec{C}\times\vec{A}\cdot\vec{B}$,
the integrand of (\ref{eqn:inteFxhA}) can be simplified to,
\begin{align}
\vec{e}_F\times\vec{h}_A\cdot\hat{n}
&=-C_AC_F\sqrt{\frac{Z_F}{Z_A}}\bigl(\vec{\nabla}_\bot f_n\times\hat{n}\bigr)\times\bigl(\vec{\nabla}_\bot a_n\times\hat{n}\bigr)\cdot\hat{n}\label{eqn:eFxhA}\\
&=-C_AC_F\sqrt{\frac{Z_F}{Z_A}}\bigl[\underbrace{\underbrace{\bigl(\vec{\nabla}_\bot{}f_n\times\hat{n}\bigr)}_{\hat{\bot}\times\hat{n}=\hat{\bot}}\cdot\hat{n}}_{\hat{\bot}\cdot\hat{n}=0}\bigr]\vec{\nabla}_\bot{}a_n\cdot\hat{n}\\
&+C_AC_F\sqrt{\frac{Z_F}{Z_A}}\bigl[\bigl(\vec{\nabla}_\bot{}f_n\times\hat{n}\bigr)\cdot\vec{\nabla}_\bot{}a_n\bigr]\underbrace{\hat{n}\cdot\hat{n}}_{\hat{n}\cdot\hat{n}=1}\label{eqn:eFxhA1}\\
&=C_AC_F\sqrt{\frac{Z_F}{Z_A}}\bigl[\bigl(\vec{\nabla}_\bot{}f_n\times\hat{n}\bigr)\cdot\vec{\nabla}_\bot{}a_n\bigr]\label{eqn:eFxhA2}\\
&=C_AC_F\sqrt{\frac{Z_F}{Z_A}}\vec{\nabla}_\bot{}a_n\times\vec{\nabla}_\bot{}f_n\cdot\hat{n}\label{eqn:eFxhA3}
\end{align}
Substituting (\ref{eqn:EABasis}) and (\ref{eqn:HFBasis}), 
the integrand of (\ref{eqn:inteAxhF}) can be simplified to,
\begin{align}
\vec{e}_A\times\vec{h}_F\cdot\hat{n}&=
C_AC_F\sqrt{\frac{Z_A}{Z_F}}\vec{\nabla}_\bot a_n\times\vec{\nabla}_\bot f_n\cdot\hat{n}\label{eqn:eAxhF3}
\end{align}

Using the results of (\ref{eqn:GFI2d4}) and (\ref{eqn:eAxhA3}), (\ref{eqn:inteAxhA}) reduces to,
\begin{align}
    \iint_S\vec{e}_A\times\vec{h}_A\cdot\hat{n}\;ds\label{eqn:inteAxhAs}
    &=C_A^2(-\gamma_\bot^2=k_\bot^2)\iint_S{a_n^2\;ds}
\end{align}
Using the results of (\ref{eqn:GFI2d4}) and (\ref{eqn:eFxhF3}), (\ref{eqn:inteFxhF}) reduces to,
\begin{align}
    \iint_S\vec{e}_F\times\vec{h}_F\cdot\hat{n}\;ds\label{eqn:inteFxhFs}
    &=C_F^2(-\gamma_\bot^2=k_\bot^2)\iint_S{f_n^2\;ds}
\end{align}
Using the results of (\ref{eqn:SFI2d}) and (\ref{eqn:eFxhA3}), (\ref{eqn:inteFxhA}) reduces to,
\begin{align}
    \iint_S\vec{e}_F\times\vec{h}_A\cdot\hat{n}\;ds\label{eqn:inteFxhAs}
    &=0
\end{align}
Using the results of (\ref{eqn:SFI2d}) and (\ref{eqn:eAxhF3}), (\ref{eqn:inteAxhF}) reduces to,
\begin{align}
    \iint_S\vec{e}_A\times\vec{h}_F\cdot\hat{n}\;ds\label{eqn:inteAxhFs}
    &=0
\end{align}
Where it is emphasized that the results were obtained with the assumption that either $a_n$ or $f_n$ is equal to zero on the boundary and that they also satisfy the transverse wave equation, $\nabla^2a_n=-k_\bot^2a_n$ or $\nabla^2f_n=-k_\bot^2f_n$.  This shows that $TE$ and $TM$ fields inside a closed fixed PEC or PMC boundary are orthogonal. Finally the normalization constants are found for the $TM_n$ case to be, 
\begin{align}
C_A=\frac{1}{(k_\bot=-j\gamma_\bot)\sqrt{\iint_S{a_n^2\;ds}}}\label{eqn:normconstA}
\end{align} 
For the $TE_n$ case,
\begin{align}
C_F=\frac{1}{(k_\bot=-j\gamma_\bot)\sqrt{\iint_S{f_n^2\;ds}}}\label{eqn:normconstF} 
\end{align} 
For the hybrid case,
\begin{align}
C_H=\frac{1}{(k_\bot=-j\gamma_\bot)\sqrt{\iint_S{a_n^2+f_n^2\;ds}}}\label{eqn:normconsthyb}
\end{align} 
Once the fields are normalized then then the $TE$ and $TM$ fields are considered orthonormal.

\subsection{Power}
The total complex power is given by the \emph{Poynting theorem} as,
\begin{align}
P &= \frac{1}{2}\iint_S\vec{E}\times\vec{H}^*\cdot d\vec{s}\\
&= \frac{1}{2}\iint_S\vec{E}_\bot\times\vec{H}_\bot^*\cdot d\vec{s}\label{eqn:poyntingthrm})
\end{align}
where $^*$ is the complex conjugate operator. Expanding the electric and magnetic fields into $TE_z$ and $TM_z$ components yields the summation of four cases,
\begin{align}
\iint_S(\vec{E}_{F}+\vec{E}_{A})\times(\vec{H}^*_{F}+\vec{H}^*_{A})\cdot\;d\vec{s}\label{eqn:defoforthognalitycylAFpwr2}
&=P_{F}+P_{A}+P_{FA}+P_{AF}
\end{align}
where
\begin{align}
P_{ F}&=\frac{1}{2}\iint_S\vec{E}_{F}\times\vec{H}^*_{F}\cdot d\vec{s}\label{eqn:IFFpwr}\\
P_{ A}&=\frac{1}{2}\iint_S\vec{E}_{A}\times\vec{H}^*_{A}\cdot d\vec{s}\label{eqn:IAApwr}\\
P_{FA}&=\frac{1}{2}\iint_S\vec{E}_{F}\times\vec{H}^*_{A}\cdot d\vec{s}\label{eqn:IFApwr}\\
P_{AF}&=\frac{1}{2}\iint_S\vec{E}_{A}\times\vec{H}^*_{F}\cdot d\vec{s}\label{eqn:IAFpwr}
\end{align}
From section \ref{sec:norm_orthogonality} it was shown that $TE_z$ and $TM_z$ fields are orthogonal and therefore $P_{FA}=P_{AF}=0$.  This means that the total power is a summation of the power in the $TE_z$ fields and the power in the $TM_z$ fields.  
\begin{align}
P = P_{F} + P_{A}\label{eqn:totalpower}
\end{align}
It was also shown that each field was expanded as a summation of $TE_z$ modes and $TM_z$ modes where individual modes were orthogonal to each other. This means that the total power is equal to the summation of the power in each individual mode.
\begin{align}
P = \sum_{i}p_{Fi} + \sum_{j}p_{Aj}
\end{align}
where $P_{F}=\sum p_{Fi}$ and $P_{A}=\sum p_{Aj}$.

\subsubsection{Power $TE_z$}
The complex power is found by,
\begin{align}
P_F = \frac{1}{2}p_F[b_F(n)+a_F(n)][b_F(n)-a_F(n)]^*
\end{align}
where,
\begin{align}
p_F = \iint_s \vec{e}_F\times\vec{h}_F^*\cdot\hat{n}\;ds
\end{align}
Substituting (\ref{eqn:EFBasis}) and (\ref{eqn:HFBasis}) yields,
\begin{align}
p_{F} &= \iint_s\left[-C_F\sqrt{Z_F}\bigl(\vec{\nabla}_\bot
    f_n(\vec{r_\bot})\times\hat{n}\bigr)\right] \times\left[-\frac{C_F}{\sqrt{Z_F}}\vec{\nabla}_\bot f_n(\vec{r_\bot})\right]^*\cdot\hat{n}\;ds\\
    &=-|C_F|^2{\frac{\sqrt{Z_F}}{\sqrt{Z_F}^*}}\iint_S\vec{\nabla}_\bot [f_n(\vec{r_\bot})]^*\times[\vec{\nabla}_\bot
    f_n(\vec{r_\bot})\times\hat{n}]\cdot\hat{n}\;ds
\end{align}
Using the vector identity $\vec{A}\times(\vec{B}\times\vec{C}) = (\vec{A}\cdot\vec{C})\vec{B}-(\vec{A}\cdot\vec{B})\vec{C}$, the complex equality ${\frac{\sqrt{Z_F}}{\sqrt{Z_F}^*}}=\frac{Z_F}{|Z_F|}$ and simplifying yields,
\begin{align}
p_F = |C_F|^2\frac{Z_F}{|Z_F|}\iint_s[\vec{\nabla}_\bot
    f_n(\vec{r_\bot})]^*\cdot \vec{\nabla}_\bot f_n(\vec{r_\bot})\;ds\label{eqn:poweruwg}
\end{align}
since $\nabla_{\bot}f_n\cdot\hat{n}=0$.  Using the results in Appendix \ref{sec:identities} (\ref{eqn:poweruwg}) simplifies to,
\begin{align}
p_F = |C_F|^2k_{\bot}^2\frac{Z_F}{|Z_F|}\iint_S |f_n(\vec{r_\bot})|^2\;ds\label{eqn:poweruwg2}
\end{align}
Substituting (\ref{eqn:normconstF})
\begin{align}
p_F &= \left|\frac{1}{k_\bot\sqrt{\iint_S{f_n^2\;ds}}}\right|^2k_{\bot}^2\frac{Z_F}{|Z_F|}\iint_s |f_n(\vec{r_\bot})|^2\;ds\label{eqn:poweruwg3}\\
&=\frac{k_{\bot}}{k_\bot^*} \frac{Z_F}{|Z_F|}\frac{\iint_S |f_n(\vec{r_\bot})|^2\;ds}{\left|\iint_s{f_n(\vec{r_\bot})^2\;ds}\right|}\label{eqn:poweruwg4}
\end{align}
If $f_n(\vec{r}_\bot)$ is a real valued function and the eigen value $k_\bot$ is also a real number then (\ref{eqn:poweruwg4}) simplifies to,
\begin{align}
p_F &=\frac{Z_F}{|Z_F|}\label{eqn:poweruwg5}
\end{align}
The total power is then found to be,
\begin{align}
P_F &= \frac{1}{2}\frac{Z_F}{|Z_F|}[b_F+a_F][b_F-a_F]^*\label{eqn:PowerTE}
\end{align}
It is interesting to note that the power is determined form the waves and the angle of the impedance.  In general the power is complex with the real part equal to the average power over one period, where the reactive part indicates that energy is being stored.  Modes that are excited below cutoff can be modeled as inductors or capacitors since they act as storage elements. 

\subsubsection{Power $TM_z$}
The complex power is found by,
\begin{align}
P_A = \frac{1}{2}p_A[b_A(n)+a_A(n)][b_A(n)-a_A(n)]^*
\end{align}
where,
\begin{align}
p_A = \iint_s \vec{e}_A\times\vec{h}_A^*\cdot\hat{n}\;ds
\end{align}
Substituting (\ref{eqn:EABasis}) and (\ref{eqn:HABasis}) yields,
\begin{align}
p_{A} &= \iint_s\left[-C_A\sqrt{Z_A}\vec{\nabla}_\bot a_n(\vec{r_\bot})\right] \times\left[\frac{C_A}{\sqrt{Z_A}}\bigl(\vec{\nabla}_\bot a_n(\vec{r_\bot})\times\hat{n}\bigr)\right]^*\cdot\hat{n}\;ds\\
    &=-|C_A|^2{\frac{\sqrt{Z_A}}{\sqrt{Z_A}^*}}\iint_s\vec{\nabla}_\bot a_n(\vec{r_\bot})\times[\vec{\nabla}_\bot
    a_n(\vec{r_\bot})\times\hat{n}]^*\cdot\hat{n}\;ds
\end{align}

Using the vector identity $\vec{A}\times(\vec{B}\times\vec{C}) = (\vec{A}\cdot\vec{C})\vec{B}-(\vec{A}\cdot\vec{B})\vec{C}$, the complex equality ${\frac{\sqrt{Z_A}}{\sqrt{Z_A}^*}}=\frac{Z_A}{|Z_A|}$ and simplifying yields,
\begin{align}
p_A = |C_A|^2\frac{Z_A}{|Z_A|}\iint_s[\vec{\nabla}_\bot
    a_n(\vec{r_\bot})]^*\cdot \vec{\nabla}_\bot a_n(\vec{r_\bot})\;ds\label{eqn:poweruwg_a}
\end{align}
since $\nabla_{\bot}f_n\cdot\hat{n}=0$.  Using the results in Appendix \ref{sec:identities} (\ref{eqn:poweruwg_a}) simplifies to,
\begin{align}
p_A = |C_A|^2k_{\bot}^2\frac{Z_A}{|Z_A|}\iint_s |a_n(\vec{r_\bot})|^2\;ds\label{eqn:poweruwg2_a}
\end{align}
Substituting (\ref{eqn:normconstA})
\begin{align}
p_A &= \left|\frac{1}{k_\bot\sqrt{\iint_s{a_n^2\;ds}}}\right|^2k_{\bot}^2\frac{Z_A}{|Z_A|}\iint_s |a_n(\vec{r_\bot})|^2\;ds\label{eqn:poweruwg3_a}\\
&=\frac{k_{\bot}}{k_\bot^*}\frac{Z_A}{|Z_A|}\frac{\iint_s |a_n(\vec{r_\bot})|^2\;ds}{\left|\iint_s{a_n(\vec{r_\bot})^2\;ds}\right|}\label{eqn:poweruwg4_a}
\end{align}
If $a_n(\vec{r}_\bot)$ is a real valued function and the eigen value $k_\bot$ is also a real number then (\ref{eqn:poweruwg4_a}) simplifies to,
\begin{align}
p_A &=\frac{Z_A}{|Z_A|}\label{eqn:poweruwg5_a}
\end{align}
The total power is then found to be,
\begin{align}
P_A &= \frac{1}{2}\frac{Z_A}{|Z_A|}[b_A+a_A][b_A-a_A]^*\label{eqn:PowerTM}
\end{align}

\subsubsection{Power of Hybrid modes}
Substituting (\ref{eqn:HhybridTotal}) and (\ref{eqn:EhybridTotal}) into (\ref{eqn:poyntingthrm}) and using the fact the $TE_n$ and $TM_n$ fields are orthogonal yields,
\begin{align}
P &= \frac{1}{2}\iint_S\vec{E}_\bot\times\vec{H}_\bot^*\cdot d\vec{s}\\
&=k_\bot^2\frac{|C_H|^2}{2}\biggl[\frac{Z_F}{|Z_F|}\iint_S|f_n|^2 ds+\frac{Z_A}{|Z_A|}\iint_S|a_n|^2 ds\biggr]\bigl(b+a\bigr)\bigl(b-a\bigr)^*
\end{align}
Substituting (\ref{eqn:normconsthyb}) gives the power of the fields for a hybrid mode,
\begin{align}
P &= \frac{1}{2}\frac{k_\bot}{k_\bot^*}\frac{\frac{Z_F}{|Z_F|}\iint_S|f_n|^2 ds+\frac{Z_A}{|Z_A|}\iint_S|a_n|^2 ds}{\biggl|\iint_S{a_n^2+f_n^2\;ds}\biggr|}\bigl(b+a\bigr)\bigl(b-a\bigr)^*
\end{align}

%\begin{equation}\label{eqn:HhybridTotal}
%    \vec{H}_\bot(\vec{r})=
%    C_H\biggl[\frac{\vec{\nabla}_\bot a_n(\vec{r_\bot})}{\sqrt{Z_A}}\times\hat{n}-\frac{\vec{\nabla}_\bot f_n(\vec{r_\bot})}{\sqrt{Z_F}}\biggr]\bigl(a(n)-b(n)\bigr)
%\end{equation}
%\begin{equation}\label{eqn:EhybridTotal}
%    \vec{E}_\bot(\vec{r})=C_\{hyb\}
%    -C_H\biggl[\sqrt{Z_F}\vec{\nabla}_\bot f_n(\vec{r_\bot})\times\hat{n}+\sqrt{Z_A}\vec{\nabla}_\bot a_n(\vec{r_\bot})\biggr]\bigl(a(n)+b(n)\bigr)
 

\section{Modal Radiation}
The open end of the waveguide can be considered as an antenna aperture in which it is possible to obtain the far-field radiation patterns.  The process for finding the radiation patterns is to sum all the modes with their respective amplitude and phases and obtain the total electric and magnetic fields. The amplitudes and phases are assumed to be known, and must be obtained by some outside method.  By the \emph{surface equivalence theorem} the fields are converted to equivalent magnetic and electric current sources,  which are then projected to the far-field by means of a near-field to far-field transformation. This transformation comes about by solving the inhomogeneous vector wave equation.  Each step will be outlined for $TE_n$ and $TM_n$ uniform waveguide modes.
\subsection{Aperture Fields}
The fields on the face of the aperture are a summation of the waveguide basis fields.  These are a summation of $TE_z$ and $TM_z$ modes such that,

\begin{align}
	\vec{E}_\bot(\vec{r})&=\sum_i\vec{e}_F(\vec{r}_\bot)_i[b_F(n)_i+a_F(n)_i]+\sum_j\vec{e}_A(\vec{r}_\bot)_j[b_A(n)_j+a_A(n)_j]\\
	\vec{H}_\bot(\vec{r})&=\sum_i\vec{h}_F(\vec{r}_\bot)_i[b_F(n)_i-a_F(n)_i]+\sum_j\vec{h}_A(\vec{r}_\bot)_j[b_A(n)_j-a_A(n)_j]
\end{align}
where $\vec{e}_F$ and $\vec{h}_F$ are defined in (\ref{eqn:EFBasis}) and (\ref{eqn:HFBasis}) and where $\vec{e}_A$ and $\vec{h}_A$ are defined in (\ref{eqn:EABasis}) and (\ref{eqn:HABasis}).
  
\subsection{Equivalent Aperture Sources}
From the \emph{surface equivalence theorem}, equivalent sources on the surface
of the aperture are found from the tangential aperture fields.  The tangential
magnetic surface currents on the face of the cylinder are defined as,
\begin{align}
\vec{J}_\bot &= \hat{n}\times\vec{H}_F+\hat{n}\times\vec{H}_A\\
&=\hat{n}\times\vec{H}^F_\bot+\hat{n}\times\vec{H}^A_\bot\\
&=\sum_{i}\hat{n}\times\vec{h}_F(\vec{r_\bot})_{i}[b_F(n)_i-a_F(n)_i]+\sum_{j}\hat{n}\times\vec{h}_A(\vec{r_\bot})_{j}[b_A(n)_j-a_A(n)_j]\label{eqn:Jperp}
\end{align}
Using the definitions of the magnetic basis fields in (\ref{eqn:HABasis}) and
(\ref{eqn:HFBasis}) yields, 
\begin{align}
\hat{n}\times\vec{h}_F(\vec{r_\bot})_i&=-\frac{C_{Fi}}{\sqrt{Z_{Fi}}}[\hat{n}\times\vec{\nabla}_\bot f_{n}(\vec{r_\bot})_i]\label{eqn:ncrossHFBasis}\\
\hat{n}\times\vec{h}_A(\vec{r_\bot})_j&= \frac{C_{Aj}}{\sqrt{Z_{Aj}}}\vec{\nabla}_\bot a_{n}(\vec{r_\bot})_j\label{eqn:ncrossHABasis}
\end{align}
Substituting (\ref{eqn:ncrossHFBasis}) and (\ref{eqn:ncrossHABasis}) into (\ref{eqn:Jperp}) yields the equivalent magentic surface currents from the summation of $TE_z$ and $TM_z$ modes,
\begin{align}
\begin{split}
\vec{J}_\bot =&-\sum_{i}\frac{C_{Fi}}{\sqrt{Z_{Fi}}}[\hat{n}\times\vec{\nabla}_\bot f_{n}(\vec{r_\bot})_i][b_F(n)_i-a_F(n)_i]\\
&+\sum_{j}\frac{C_{Aj}}{\sqrt{Z_{Aj}}}\vec{\nabla}_\bot a_{n}(\vec{r_\bot})_j[b_A(n)_j-a_A(n)_j]\label{eqn:Jperp2}
\end{split}
\end{align}
The tangential electric surface currents are also defined as,
\begin{align}
\vec{M}_\bot &= -\hat{n}\times\vec{E}_F-\hat{n}\times\vec{E}_A\\
&= -\hat{n}\times\vec{E}^F_\bot-\hat{n}\times\vec{E}^F_\bot\\
&=\sum_i-\hat{n}\times\vec{e}_F(\vec{r_\bot})_i[b_F(n)_i+a_F(n)_i]+\sum_j-\hat{n}\times\vec{e}_A(\vec{r_\bot})_j[b_A(n)_i+a_A(n)_i]\label{eqn:Mperp}
\end{align}
where,
\begin{align}
-\hat{n}\times\vec{e}_F(\vec{r_\bot})_i&={C_{Fi}}{\sqrt{Z_{Fi}}}\vec{\nabla}_\bot f_{n}(\vec{r_\bot})_i\label{eqn:ncrossEABasis}\\
-\hat{n}\times\vec{e}_A(\vec{r_\bot})_j&={C_{Aj}}{\sqrt{Z_{Aj}}}[\hat{n}\times\vec{\nabla}_\bot a_{n}(\vec{r_\bot})_j]\label{eqn:ncrossEFBasis}
\end{align}
Substituting (\ref{eqn:ncrossEFBasis}) and (\ref{eqn:ncrossEABasis}) into (\ref{eqn:Mperp}) yields the equivalent electric surface currents from the summation of $TE_z$ and $TM_z$ modes,
\begin{align}
\begin{split}
\vec{M}_\bot &= \sum_i{C_{Fi}}{\sqrt{Z_{Fi}}}\vec{\nabla}_\bot f_{n}(\vec{r_\bot})_i[b_F(n)_i+a_F(n)_i]\\
&+\sum_j{C_{Aj}}{\sqrt{Z_{Aj}}}[\hat{n}\times\vec{\nabla}_\bot a_{n}(\vec{r_\bot})_j][b_A(n)_i+a_A(n)_i]\label{eqn:Mperp2}
\end{split}
\end{align}


\subsection{Near-Field to Far-Field Transformation}
Solutions to the non-homogeneous wave equations
\begin{align}
(\nabla^2+k^2)\vec{A} &= -\vec{J}\\
(\nabla^2+k^2)\vec{F} &= -\vec{M}\\
\end{align}
are given as
\begin{align}
\vec{A}(\vec{r}) &= \frac{1}{4\pi}\iiint_{V}\vec{J}(\vec{r}')\frac{e^{-jkR}}{R}\;dv'\\
\vec{F}(\vec{r}) &= \frac{1}{4\pi}\iiint_{V}\vec{M}(\vec{r}')\frac{e^{-jkR}}{R}\;dv'\\
\end{align}
where
\begin{align}
R = \vec{r}-\vec{r}'
\end{align}
When the currents are defined only over a surface then,
\begin{align}
\vec{A_\bot}(\vec{r}) &= \frac{1}{4\pi}\iint_{S'}\vec{J_\bot}(\vec{r_\bot}')\frac{e^{-jkR}}{R}\;ds'\\
\vec{F_\bot}(\vec{r}) &= \frac{1}{4\pi}\iint_{S'}\vec{M_\bot}(\vec{r_\bot}')\frac{e^{-jkR}}{R}\;ds'\\
\end{align}
where $\vec{r_\bot}'$ is defined only on the surface and $\vec{J}_\bot$ and $\vec{M}_\bot$ are surface currents whose components normal to the surface are zero.  

When far-field approximations are carried out on the above transformations, the magnetic vector potential is approximately equal to,
\begin{align}
\vec{A_\bot}(\hat{r}) \approx \frac{e^{-jkr}}{4\pi r}\vec{N}_\bot(\hat{r})
\end{align}
where,
\begin{align}
\vec{N}_\bot(\hat{r}) &= \iint_{S'}\vec{J}_\bot(\vec{r}')e^{jk\hat{r}\cdot\vec{r}'}\;ds'\label{eqn:Nperp} 
\end{align}
The electric vector potential in the far-field is found to be approximately equal to, 
\begin{align}
\vec{F_\bot}(\hat{r}) \approx \frac{e^{-jkr}}{4\pi r}\vec{L}_\bot(\hat{r})
\end{align}
where,
\begin{align}
\vec{L}_\bot(\hat{r}) &= \iint_{S'}\vec{M}_\bot(\vec{r}')e^{jk\hat{r}\cdot\vec{r}'}\;ds'\label{eqn:Lperp} 
\end{align}
The unit vector $\hat{r}$ indicates the direction in which the radiation pattern is to be evaluated.  It is most convenient to describe these directions in spherical coordinates while expanding the vector in the rectangular coordinate system to get,
\begin{align}
\hat{r} &= \sin{\theta}\cos{\phi}\;\hat{x}+\sin{\theta}\sin{\phi}\;\hat{y}+\cos{\theta}\hat{z}
\end{align}
The vector $\vec{r}'$ is a displacement vector which describes the source locations.  The location of the sources are most conveniently described in a coordinate system that best fits the geometry of the problem.  
\begin{align}
\vec{r'}&=x'\hat{x}+y'\hat{y}+z'\hat{z}
\end{align}
The dot product of each of these vectors is then given as,
\begin{align}
\hat{r}\cdot\vec{r} &= \sin{\theta}\cos{\phi}\;x'+\sin{\theta}\sin{\phi}\;y'+\cos{\theta}z'
\end{align}

Substituting (\ref{eqn:Jperp2}) into (\ref{eqn:Nperp}) gives,
\begin{multline}
\vec{N}_\bot =\sum_{i}\frac{-C_{Fi}}{\sqrt{Z_{Fi}}}\;\hat{n}\times\iint_{S'}[\vec{\nabla}_\bot f_{n}(\vec{r_\bot}')_i]e^{jk\hat{r}\cdot\vec{r}'}\;ds'[b_F(n)_i-a_F(n)_i]\\
+\sum_{j}\frac{C_{Aj}}{\sqrt{Z_{Aj}}}\iint_{S'}[\vec{\nabla}_\bot a_{n}(\vec{r_\bot}')_j]e^{jk\hat{r}\cdot\vec{r}'}\;ds'[b_A(n)_j-a_A(n)_j]\label{eqn:Nperp2}
\end{multline}
Substituting (\ref{eqn:Mperp2}) into (\ref{eqn:Lperp}) gives,
\begin{multline}
\vec{L}_\bot = \sum_i{C_{Fi}}{\sqrt{Z_{Fi}}}\iint_{S'}[\vec{\nabla}_\bot f_{n}(\vec{r_\bot}')_i]e^{jk\hat{r}\cdot\vec{r}'}\;ds'[b_F(n)_i+a_F(n)_i]\\
+\sum_j{C_{Aj}}{\sqrt{Z_{Aj}}}\;\hat{n}\times\iint_{S'}[\vec{\nabla}_\bot a_{n}(\vec{r_\bot}')_j]e^{jk\hat{r}\cdot\vec{r}'}\;ds'[b_A(n)_i+a_A(n)_i]\label{eqn:Lperp2}
\end{multline}
Each of the integrals in (\ref{eqn:Nperp2}) and (\ref{eqn:Lperp2}) have the form
\begin{align}
	\iint_{S'}\Psi\vec{\nabla}_\bot \Phi\;ds'
\end{align}
where $\Psi = e^{jk\hat{r}\cdot\vec{r}'}$ and $\Phi = f_{n}(\vec{r_\bot}')$ or $\Phi = a_{n}(\vec{r_\bot}')$.
Expaning the gradient of two scalar functions
\begin{align}
\vec{\nabla}_\bot[\Phi\Psi]= \Phi\vec{\nabla}_\bot\Psi + \Psi\vec{\nabla}_\bot\Phi
\end{align}
and substituting yields
\begin{align}
	\iint_{S}\Psi\vec{\nabla}_\bot \Phi\;ds& = \iint_{S}\vec{\nabla}_\bot[\Phi\Psi]\;ds - \iint_{S}\Phi\vec{\nabla}_\bot\Psi\;ds\label{eqn:tempintegral1}
\end{align}
Using the \emph{surface gradient theorem} the first integral on the RHS in (\ref{eqn:tempintegral1}) yields, 
\begin{align}
	\iint_S \vec{\nabla}_\bot[\Phi\Psi]\;ds = \oint_C \Phi\Psi\hat{u}\;d\ell
\end{align}
where $\hat{u}$ is a unit vector tangent to the curve $C$ and perendicular to the surface of the aperture.
If the curve is evaluated on the boundary of the waveguide then for $TM_n$ modes $\Phi=a_n = 0$ and therefore,
\begin{align}
	\oint_C \Phi\Psi\hat{u}\;d\ell=\oint_C a_{n}(\vec{r_\bot}')e^{jk\hat{r}\cdot\vec{r}'}\hat{u}'\;d\ell'=0
\end{align}
For $TE_n$ modes $\Phi = f_n$ and the line integral equates to, 
\begin{align}
	\oint_C \Phi\Psi\hat{u}\;d\ell=\oint_C f_{n}(\vec{r_\bot}')e^{jk\hat{r}\cdot\vec{r}'}\hat{u}'\;d\ell'
\end{align}
If $f_n$ is seperable $f_n(u,v) = U(u)V(v)$ and because of the boundary condition for $TE_n$ modes $\frac{\partial \Phi}{\partial u}=U'(b)V(v)=0$ then $U(b)$ is constant evaluated on the boundary ($u=b$), therfore
\begin{align}
	\oint_C \Phi\Psi\hat{u}\;d\ell=U(b)\oint_C V(v')e^{jk\hat{r}\cdot\vec{r}'}\hat{u}'\;d\ell'
\end{align}

The second integral on the RHS in (\ref{eqn:tempintegral1}) can be simplified to,
\begin{align}
	\iint_{S}\Phi\vec{\nabla}_\bot\Psi\;ds = jk\hat{r}_\bot\iint_{S}\Phi e^{jk\hat{r}\cdot\vec{r}'}\;ds
\end{align}
since,
\begin{align}
\vec{\nabla}_\bot\Psi=\vec{\nabla}_\bot' e^{jk\hat{r}\cdot\vec{r}'}=jk\hat{r}_\bot e^{jk\hat{r}\cdot\vec{r}'}
\end{align} 
where,
\begin{align}
	\hat{r}_\bot &= \sin\theta\cos\phi\hat{x} + \sin\theta\sin\phi\hat{y} + 0\hat{z}\\
	&=(\cos\phi\hat{x} + \sin\phi\hat{y})\sin\theta\\
	&=\hat{\rho}\sin\theta
\end{align}

Therefore, for $TE_z$ modes
\begin{multline}
	\iint_{S'}[\vec{\nabla}_\bot' f_{n}(\vec{r_\bot}')_i]e^{jk\hat{r}\cdot\vec{r}'}\;ds'=\\
	\oint_C f_{n}(\vec{r_\bot}')_i e^{jk\hat{r}\cdot\vec{r}'}\hat{u}'\;d\ell'-jk\hat{r}_\bot\iint_{S'}f_{n}(\vec{r_\bot}')_i\;e^{jk\hat{r}\cdot\vec{r}'}\;ds'
\end{multline}
and for $TM_z$ modes
\begin{align}
	\iint_{S'}[\vec{\nabla}_\bot' a_{n}(\vec{r_\bot}')_j]e^{jk\hat{r}\cdot\vec{r}'}\;ds'&=-jk\hat{r}_\bot\iint_{S'}a_{n}(\vec{r_\bot}')_j\;e^{jk\hat{r}\cdot\vec{r}'}\;ds'
\end{align}

Substituting these results gives the final form for $\vec{N}_\bot$ and $\vec{L}_\bot$,
\begin{multline}
\vec{N}_\bot(\hat{r}) = \sum_{j}\frac{C_{Aj}}{\sqrt{Z_{Aj}}}\left[-jk\hat{r}_\bot\iint_{S'}a_{n}(\vec{r_\bot}')_j\;e^{jk\hat{r}\cdot\vec{r}'}\;ds'\right][b_A(n)_j-a_A(n)_j]\\
+\sum_{i}\frac{-C_{Fi}}{\sqrt{Z_{Fi}}}\;\hat{n}\times\left[\oint_C f_{n}(\vec{r_\bot}')_i e^{jk\hat{r}\cdot\vec{r}'}\hat{u}'\;d\ell'-jk\hat{r}_\bot\iint_{S'}f_{n}(\vec{r_\bot}')_i\;e^{jk\hat{r}\cdot\vec{r}'}\;ds'\right][b_F(n)_i-a_F(n)_i]\label{eqn:Nperp3}
\end{multline}

\begin{multline}
\vec{L}_\bot(\hat{r}) = \sum_j{C_{Aj}}{\sqrt{Z_{Aj}}}\;\hat{n}\times\left[-jk\hat{r}_\bot\iint_{S'}a_{n}(\vec{r_\bot}')_j\;e^{jk\hat{r}\cdot\vec{r}'}\;ds'\right][b_A(n)_i+a_A(n)_i]\\
+\sum_i{C_{Fi}}{\sqrt{Z_{Fi}}}\left[\oint_C f_{n}(\vec{r_\bot}')_i e^{jk\hat{r}\cdot\vec{r}'}\hat{u}'\;d\ell'-jk\hat{r}_\bot\iint_{S'}f_{n}(\vec{r_\bot}')_i\;e^{jk\hat{r}\cdot\vec{r}'}\;ds'\right][b_F(n)_i+a_F(n)_i]\label{eqn:Lperp3}
\end{multline}
 
Converting to $\vec{N}_\bot$ and $\vec{L}_\bot$ to spherical coordiantes the electric far-field is found by,
\begin{align}
E_r&\approx0\\
E_\theta&\approx-\frac{jke^{-jkr}}{4\pi r}\left(L_\phi+\eta N_\theta\right)\label{eqn:Ethetaff}\\
E_\phi&\approx\frac{jke^{-jkr}}{4\pi r}\left(L_\theta-\eta N_\phi\right)\label{eqn:Ephiff}
\end{align}
where the  magnetic far-field is,
\begin{align}
H_r&\approx0\\
H_\theta&\approx\frac{jke^{-jkr}}{4\pi r}\left(N_\phi-\frac{L_\theta}{\eta}\right)\\
H_\phi&\approx-\frac{jke^{-jkr}}{4\pi r}\left(N_\theta+\frac{L_\phi}{\eta}\right)
\end{align}
The directivity is calculated from the electric fields by,
\begin{align}
D(\theta,\phi)=\Re\left\{\frac{2\pi}{\eta^*P}\left(|E_\theta|^2+|E_\phi|^2\right)r^2\right\}
\end{align}

\subsection{Plane waves and Directivity}
A solution to the vector wave equation,
\begin{align}
\nabla^2\vec{E}=-k^2\vec{E}
\end{align}  
is given by,
\begin{align}
\vec{E} = \vec{E_0}^+e^{-j\vec{k}\cdot{\vec{r}}}+\vec{E_0}^-e^{j\vec{k}\cdot{\vec{r}}}
\end{align}
where $\vec{k}=k\hat{k}$ is a propagation vector, $\vec{r}$ is a displacment vector and $\vec{E_0}$ is a constant.  The solution is a summation of a forward traveling wave $\vec{E_0}^+e^{-j\vec{k}\cdot{\vec{r}}}$ and a backward traveling wave $\vec{E_0}^-e^{j\vec{k}\cdot{\vec{r}}}$.  The directions in which the wave travels is found by transforming to the time domain and letting each term equal a constant. Transforming to the time domain and using Eulers identity $e^{j\phi} = \cos\phi+j\sin\phi$ yields,
\begin{align}
\vec{E}(\vec{k}\cdot\vec{r},t)&=\Re{\vec{E}(\vec{k}\cdot\vec{r})e^{j\omega{t}}}\\
&= \Re\vec{E_0}^+e^{-j\vec{k}\cdot{\vec{r}}}e^{j\omega{t}}+\Re\vec{E_0}^-e^{j\vec{k}\cdot{\vec{r}}}e^{j\omega{t}}\\
&= \vec{E_0}^+\cos({\omega{t}-\vec{k}\cdot{\vec{r}}})+\vec{E_0}^-\cos({\omega{t}}+{\vec{k}\cdot{\vec{r}}})
\end{align}
First set the left term equal to a vector constant $\vec{E_0}^+$ and then dot multiply by this vector to get,
\begin{align}
\cos({\omega{t}-\vec{k}\cdot{\vec{r}}})=1
\end{align}
The solution to this equation is,
\begin{align}
\omega{t}&=\vec{k}\cdot{\vec{r}}\\
&= kr\hat{k}\cdot\hat{r}
\end{align}
Solving for $r$ and then differentiating with respect to time yields the velocity,
\begin{align}
v=\frac{dr}{dt}= \frac{\omega}{k}\frac{1}{\hat{k}\cdot\hat{r}}
\end{align}
in which it is seen that the velocity is positive.  Following a similar procedure for the other term yields a negative velocity.  For this discussion, only the following forward traveling wave will be considered,
\begin{align}
\vec{E} = \vec{E_0}^+e^{-j\vec{k}\cdot{\vec{r}}}\label{eqn:planewaveforward}
\end{align}
Therefore all results derived below will be based upon this assumption.  The magnetic field is found by substituting (\ref{eqn:planewaveforward}) into Faraday's law and solving for $\vec{H}$ to get,
\begin{align}
\vec{H} &= \frac{-1}{j\omega\mu'}\nabla\times\vec{E}\\
&= \frac{-1}{j\omega\mu'}\nabla\times\left(\vec{E_0}^+e^{-j\vec{k}\cdot{\vec{r}}}\right)\\
&= \frac{-1}{j\omega\mu'}\left[\left(\nabla\times\vec{E_0}^+\right)e^{-j\vec{k}\cdot{\vec{r}}}+\left(\nabla e^{-j\vec{k}\cdot{\vec{r}}}\times\vec{E_0}^+\right)\right]\\
&= \frac{-1}{j\omega\mu'}\nabla e^{-j\vec{k}\cdot{\vec{r}}}\times\vec{E_0}^+
\end{align}
since $\nabla\times\vec{E_0}^+=0$.  It is also seen that,
\begin{align}
\nabla e^{-j\vec{k}\cdot{\vec{r}}}&=-j\vec{k}e^{-j\vec{k}\cdot{\vec{r}}}
\end{align}
Substituting yields,
\begin{align}
\vec{H}&=\frac{1}{\eta}\left(\hat{k}\times\vec{E}\right)\label{eqn:planewaveH}
\end{align}
where
\begin{align}
\eta=\frac{\omega\mu'}{k}=\sqrt{\frac{\mu'}{\varepsilon'}}
\end{align}
It should be emphasized that the result in (\ref{eqn:planewaveH}) is only valid for forward traveling waves.  For a negative traveling wave this result would change sign.  From Gauss's E-field law in a source free region and constant constitutive parameters it is seen that,
\begin{align}
\begin{split}
\nabla\cdot\vec{E}
=\nabla\cdot\left(\vec{E_0}^{+}e^{-j\vec{k}\cdot{\vec{r}}}\right)
=\left(\nabla\cdot\vec{E_0}^{+}\right)e^{-j\vec{k}\cdot{\vec{r}}}+\vec{E_0}^{+}\cdot\left(\nabla e^{-j\vec{k}\cdot{\vec{r}}}\right)\\
=-j\vec{k}\cdot\vec{E_0}^+e^{-j\vec{k}\cdot{\vec{r}}}=-j\vec{k}\cdot\vec{E}=0
\end{split}
\end{align}
The result of $\vec{k}\cdot\vec{E}=0$ shows that the two vectors are perpendicular, therefore the electric filed is always perpendicular to the direction of propagation.  Also (\ref{eqn:planewaveH}) shows that the magnetic field is perpendicular to both the electric field and the direction of propagation. If $\eta$ is real then $\vec{E}$ and $\vec{H}$ will be in phase, if $\eta$ is complex then they will be out of phase. 

Power is found from Poynting's theorem to be,
\begin{align}
P&=\frac{1}{2}\Re\left\{\iint\vec{E}\times\vec{H}^*\cdot\;d\vec{s}\right\}\\
\end{align}
Substituting (\ref{eqn:planewaveH}) gives,
\begin{align}
P&=\frac{1}{2}\Re\left\{\iint\vec{E}\times\left[\frac{1}{\eta}\left(\hat{k}\times\vec{E}\right)\right]^*\cdot\;d\vec{s}\right\}\\
&=\Re\left\{\frac{1}{2\eta^*}\iint\vec{E}\times\left(\hat{k}\times\vec{E}^*\right)\cdot\;d\vec{s}\right\}\\
&=\Re\left\{\frac{1}{2\eta^*}\iint\left(\vec{E}\cdot\vec{E}^*\right)\hat{k}\cdot\;d\vec{s}\right\}
\end{align}
Expanding in the spherical coordinate system yields,
\begin{align}
P&=\frac{1}{2}\Re\left\{\int_0^{2\pi}\int_0^{\pi}\left(E_\theta H_\phi^*-E_\phi H_\theta^*\right)r^2\;\sin\theta\;d\theta d\phi\right\}\\
&=\Re\left\{\frac{1}{2\eta^*}\int_0^{2\pi}\int_0^{\pi}\left(|E_\theta|^2+|E_\phi|^2\right)r^2\;d\Omega\right\}
\end{align}
where $d\Omega=\sin\theta\;d\theta d\phi$ is known as the \emph{element of solid angle}. \emph{Radiation intensity} is defined as,
\begin{align}
U(\theta,\phi)=\Re\left\{\frac{1}{2\eta^*}\left(|E_\theta|^2+|E_\phi|^2\right)r^2\right\}
\end{align}
\begin{align}
U_{ave} = \frac{P}{4\pi}
\end{align}
Directivity is defined as 
\begin{align}
D(\theta,\phi) = \frac{U(\theta,\phi)}{U_{ave}}=\Re\left\{\frac{2\pi}{\eta^*P}\left(|E_\theta|^2+|E_\phi|^2\right)r^2\right\}
\end{align}
where $P$ is defined in (\ref{eqn:PowerTE}) and (\ref{eqn:PowerTM}).

